package field

import (
	"yunj/pkg/yunj/core/builder/form"
)

// 隐藏域
type Hidden struct {
	form.Field
}

func NewHidden(id string, verifyTitle ...string) *Hidden {
	f := &Hidden{}
	form.SetFieldInstance(&f.Field, f)
	f.SetFieldId(id)
	if len(verifyTitle) > 0 {
		f.SetVerifyTitle(verifyTitle[0])
	}
	return f
}

// 设置验证标题
func (f *Hidden) SetVerifyTitle(verifyTitle string) *Hidden {
	f.VerifyTitle = verifyTitle
	return f
}

// 设置默认值
func (f *Hidden) SetDefault(def any) *Hidden {
	f.Default = def
	return f
}

// 设置验证规则
func (f *Hidden) SetVerify(rule string) *Hidden {
	f.Verify = rule
	return f
}

// 增加验证规则
func (f *Hidden) AddVerify(rule string) *Hidden {
	f.AddFieldVerify(rule)
	return f
}
